package com.fantastic.web.controller.admin;

import com.fantastic.common.exception.enums.RespStatusInfo;
import com.fantastic.common.result.ResultData;
import com.fantastic.model.pojo.zjs.Integral;
import com.fantastic.model.pojo.zjs.Member;
import com.fantastic.service.zjs.IntegralService;
import com.fantastic.service.zjs.MemberService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author: rxx
 * @since: 2024/6/4 16:15
 * @description: 会员卡信息请求控制器
 */
@RestController
@RequestMapping("/member")
public class MemberControllerAdmin {

    @Resource
    private MemberService memberService;

    /**
     * 查询会员卡信息
     *
     * @param member
     * @param pageSize
     * @param pageNum
     * @return
     */
    @GetMapping("/listMember")
    public ResultData listMember(Member member,
                                 @RequestParam(name = "page",
                                         defaultValue = "1") int pageNum,
                                 @RequestParam(name = "limit", defaultValue = "9999999") int pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        List<Member> list = memberService.listMember(member);
        PageInfo<Member> pageInfo = new PageInfo<>(list);
        return new ResultData(RespStatusInfo.OK, pageInfo);
    }

    /**
     * 查询单个会员卡信息
     *
     * @param memberId
     * @return
     */
    @GetMapping("/getMember")
    public ResultData getMember(Integer memberId) {
        return new ResultData(RespStatusInfo.OK, memberService.getMember(memberId));
    }

    /**
     * 添加会员卡信息
     *
     * @param member
     * @return
     */
    @PostMapping("/insertMember")
    public ResultData insertMember(MultipartFile memberFile, Member member) {
        return new ResultData(RespStatusInfo.OK, memberService.insertMember(memberFile, member));
    }

    /**
     * 修改会员卡信息
     *
     * @param member
     * @return
     */
    @PostMapping("/updateMember")
    public ResultData updateMember(MultipartFile memberFile, Member member) {
        return new ResultData(RespStatusInfo.OK, memberService.updateMember(memberFile, member));
    }

    /**
     * 删除会员卡信息
     *
     * @param memberId
     * @return
     */
    @PostMapping("/deleteMember")
    public ResultData deleteMember(Integer memberId) {
        return new ResultData(RespStatusInfo.OK, memberService.deleteMember(memberId));
    }


}
